package com.tj.collection.controller.admin.response;

import com.fqgj.common.api.ResponseData;
import com.fqgj.common.utils.CollectionUtils;
import com.tj.collection.db.domain.Menu;

import java.util.ArrayList;
import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * User: sm
 * Date: 2017/3/13
 * Time: 下午4:10
 */
public class MenuListResponse implements ResponseData {

    private List<Item> list = new ArrayList<>();

    public MenuListResponse(List<Menu> menuList) {
        if (CollectionUtils.isEmpty(menuList)) {
            return;
        }
        for (Menu menu : menuList) {
            Item item = new Item(menu.getMenuId(), menu.getKey(), menu.getValue());
            item.setMenuType(menu.getMenuType());
            list.add(item);
        }

    }

    private class Item {
        private Long id;

        private String name;

        private String url;

        /**
         * 菜单类型 0-内部使用 1-商户通用
         */
        private Integer menuType;

        public Item(Long id, String name, String url) {
            this.id = id;
            this.name = name;
            this.url = url;
        }

        public Long getId() {
            return id;
        }

        public Item setId(Long id) {
            this.id = id;
            return this;
        }

        public String getName() {
            return name;
        }

        public Item setName(String name) {
            this.name = name;
            return this;
        }

        public String getUrl() {
            return url;
        }

        public Item setUrl(String url) {
            this.url = url;
            return this;
        }

        public Integer getMenuType() {
            return menuType;
        }

        public Item setMenuType(Integer menuType) {
            this.menuType = menuType;
            return this;
        }
    }
}
